package com.santu.edu.supporter.biz.user.dao;

import com.santu.edu.supporter.biz.user.dao.mapper.UserMapper;
import com.santu.edu.supporter.biz.user.pojo.dto.UserDTO;
import com.santu.edu.supporter.biz.user.pojo.po.UserPO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;

/**
 * @author luoyaoqi
 * @createTime 2024/2/20
 * @description
 */
@Repository
@RequiredArgsConstructor
public class UserDao {

    private final UserMapper userMapper;
    public void addUser(UserDTO dto) {
        UserPO item = UserPO.createItem(dto);
        userMapper.insertOne(item);
    }

    public void updateUser(UserDTO dto) {
        UserPO item = UserPO.createItem(dto);
        userMapper.updateOne(item);
    }

    public void removeUser(String userId) {
        userMapper.removeUser(userId);
    }

    public UserDTO getUserById(String userId) {
        return userMapper.getUserById(userId);
    }
}
